/**
 * Created by TL on 2019/5/20/020.
 */
import CZML_GENERALTOOLS_CLASS from "./../main/CZML_GENERALTOOLS_CLASS.js"
/**
 *添加地面站
 * @param id <String> 全局唯一ID，服务化平台给出的UUID
 * @param name <String> 地面站名称
 * @param position <Array> 地面站位置，[经度,纬度,高度]([30,30,0])
 * @param ModelVisible <Boolean>三维模型是否可见
 * @param Model3DPath <String> 三维模型路径
 * @param ModelSize <Number> 三维模型大小,1
 * @param MarkerVisible <Boolean> 二维标签是否可见
 * @param MarkerPath <String> 二维标签图片路径
 * @param MaekerPixelSize <Number> 二维标签图片大小,1
 * @param MarkerColor <Array> 二维标签颜色，[R,G,B,255]（[255,0,0,255]）
 * @param MarkerXOriginPos <String> 二维标签水平对齐，三种可选（"CENTER"，"LEFT"，"RIGHT"）
 * @param MarkerYOriginPos <String> 二维标签垂直对齐，三种可选（"CENTER"，"LEFT"，"RIGHT"）
 * @param Distance <Number> 二三维图标切换的距离，5.5e6
 * @returns <Boolean> 新添加id时返回true，替换存在id时返回false
 */
class CZML_Facility {
    constructor(viewer, id, name, position, ModelVisible, Model3DPath, ModelSize, MarkerVisible,
                MarkerPath, MaekerPixelSize, MarkerColor, MarkerXOriginPos, MarkerYOriginPos, Distance) {
        this._viewer = viewer
        this.id = id
        this.name = name
        this.position = position
        this.ModelVisible = ModelVisible
        this.Model3DPath = Model3DPath
        this.ModelSize = ModelSize
        this.MarkerVisible = MarkerVisible
        this.MarkerPath = MarkerPath
        this.MaekerPixelSize = MaekerPixelSize
        this.MarkerColor = MarkerColor
        this.MarkerXOriginPos = MarkerXOriginPos
        this.MarkerYOriginPos = MarkerYOriginPos
        this.Distance = Distance
        this.FacilityData = {
            id: id,
            availability: CZML_GENERALTOOLS_CLASS.HEU_ScenarioTime,
            name: name,
            billboard: {
                eyeOffset: {
                    cartesian: [0, 0, 0]
                },
                horizontalOrigin: MarkerXOriginPos,
                image: MarkerPath,
                pixelOffset: {
                    cartesian2: [0, 0]
                },
                scale: MaekerPixelSize,
                distanceDisplayCondition: {
                    distanceDisplayCondition: [Distance]
                },
                show: MarkerVisible,
                verticalOrigin: MarkerYOriginPos
            },
            model: {
                gltf: Model3DPath,
                distanceDisplayCondition: {
                    distanceDisplayCondition: [0, Distance]
                },
                scale: ModelSize,
                show: ModelVisible,
                runAnimations: false
            },
            label: {
                fillColor: {
                    rgba: MarkerColor
                },
                font: "11pt Lucida Console",
                horizontalOrigin: "LEFT",
                pixelOffset: {
                    cartesian2: [10, 0]
                },
                show: MarkerVisible,
                style: "FILL_AND_OUTLINE",
                text: name,
                verticalOrigin: "CENTER"
            },
            position: {
                cartographicDegrees: position
            }
        }
        this.CZML_AddFacility()
    }

    CZML_AddFacility() {
        // 插入该数据对象
        const ret = CZML_GENERALTOOLS_CLASS.InsertModelObjectInformation(this.id, this.FacilityData, true)
        // 上图
        CZML_GENERALTOOLS_CLASS.Upper(this._viewer)
        return ret
    }
}
export default CZML_Facility
